/**
 * 
 */
package com.star.util.xml;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 * @ClassName: JaxbDateSerializer
 * @Description: TODO
 * @author starhq
 * @createtime 2014年8月1日 上午10:23:14
 * @email : jian.wang@shinsoft.net
 * @modify by TODO
 * @resaon
 * @edittime
 * @version 1.0
 * @copyright shinsoft
 */
public class JaxbDateSerializer extends XmlAdapter<String, Date> {

	private static final SimpleDateFormat DAYFORMAT = new SimpleDateFormat(
			"yyyy-MM-dd");

	private static final SimpleDateFormat FULLFORMAT = new SimpleDateFormat(
			"yyyy-MM-dd HH:mm:ss");

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
	 */
	@Override
	public Date unmarshal(String v) throws Exception {
		return DAYFORMAT.parse(v);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
	 */
	@Override
	public String marshal(Date v) throws Exception {
		return DAYFORMAT.format(v);
	}

}
